package com.koron.css2.serviceManage.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.TServiceLog;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.mapper.TServiceLogMapper;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class ServiceLogQuery implements ServerInterface {

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {

		@SuppressWarnings("rawtypes")
		MessageBean<TServiceLog> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", TServiceLog.class);

		try {
			String logId = req.getData()+"";
			TServiceLogMapper mapper = factory.getMapper(TServiceLogMapper.class);
			TServiceLog logBean = mapper.selectLogById(logId);
			info.setData(logBean);
		} catch (Exception e) {
			info.setCode(Constant.MESSAGE_INT_FAIL);
			info.setDescription(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return info;
	}

}
